package com.olympus.hermes.common.constants;

import java.util.Optional;

/**
 *
 * @author Mickey
 * @since 2019.11.24
 */
public enum CodeEnum implements BaseEnum<CodeEnum> {

    /**
     *
     */

    SUCCESS(1,"操作成功"),
    FAIL(0,"操作失败"),

    ;

    private final Integer code;
    private final String msg;

    CodeEnum(Integer code, String msg){
        this.code = code;
        this.msg = msg;
    }

    @Override
    public Integer getCode() {
        return this.code;
    }

    @Override
    public String getName() {
        return this.msg;
    }

    public static Optional<CodeEnum> of(Integer code) {
        return Optional.ofNullable(BaseEnum.parseByCode(CodeEnum.class,code));
    }
}
